export default {
  name: 'router-link',
  props: {
    to: {
      type: String,
      required: true
    },
    tag: {
      type: String,
      default: 'a'
    }
  },
  render(h) {
    return h(this.tag, {
      attrs: {
        href: this.to
      },
      on: {
        click: this.clickHandler
      }
    }, [this.$slots.default])
  },
  methods: {
    clickHandler(e) {
      this.$router.push(this.to)
      //阻止时间默认行为，要不然浏览器会刷新
      e.preventDefault();
    }
  }
}